#include "transactionvieweditdialog.h"
#include "core/constants.h"

void TransactionViewEditDialog::setTransaction(TransactionModel *transaction)
{
    this->customerBox->setEditText(transaction->getCustomer()->getName());
    int isPaid = transaction->isPaid();

    if (isPaid == 1) {
        this->paidBox->setEditText("Paid");
    }
    else
        this->paidBox->setEditText("Unpaid");
}

void TransactionViewEditDialog::initializeUiComponents() {
    this->itemBox->hide();
    this->itemLabel->hide();

    this->stockBox->hide();
    this->stockLabel->hide();

    this->validityBox->show();

    this->stockControlButtonsBox->close();

    this->headerLabel->setText("Edit Transaction details");
    this->subHeaderLabel->setText("Modify your Transaction's details as needed");
}

TransactionViewEditDialog::TransactionViewEditDialog(QWidget *parent,
                                                     TransactionModel *transaction) :
    TransactionViewAddDialog(parent)
{
    this->initializeUiComponents();
    this->setWindowTitle("Edit a Transaction");
    this->setTransaction(transaction);
}
